var StatisticsM = {
	data: {},
	dialog: null,
	init: function(){
		var boss = this;
		
		$("#returnCameraBtn, #returnCarBtn1, #returnCarBtn2").hide();
		boss.initCarLayout();
		boss.initEvent();
	},
	initEvent: function(){
		var boss = this;
		
		$(".tabMenuContent .publicTabMenuUl li").bind("click",function(){
			$(".tabMenuContent .publicTabMenuUl li").removeClass("select");
			$(this).addClass("select");
			var tag = $(this).attr("tag");
			$(".tabContent").hide();
			$("#"+tag).show();
			if(tag == "cameraStatisticsTab"){
				var loaded = $("#camera_statistics_grid").attr("loaded");
				if(loaded){
					return;
				}else{
					boss.initCameraLayout();
				}
			}else if(tag == "carStatisticsTab"){
				var loaded = $("#car_statistics_grid").attr("loaded");
				if(loaded){
					return;
				}else{
					boss.initCarLayout();
				}
			}else if(tag == "userStatisticsTab"){
				var loaded = $("#user_statistics_grid").attr("loaded");
				if(loaded){
					return;
				}else{
					boss.initUserLayout();
				}
			}
		});
		
		boss.initCameraEvent();
		boss.initCarEvent();
		boss.initUserEvent();
	},
	initCameraLayout: function(){
		var boss = this;

		boss.data = {};
		$("#statistics_grid").css("width", "1700px");
		var day = moment().format("YYYY-MM-DD");
		boss.data.startdate = day + " 00:00";
		boss.data.enddate = day + " 23:59";
		$("#CameraNowDay").html(day);
		$("#camera_date_hidden").val(day);
		boss.initCameraStatistics(boss.data);
	},
	initCarLayout: function(){
		var boss = this;

		boss.data = {};
		$("#CarTimeTr").hide();
		$("input[name='startdate'], input[name='enddate']").datetimepicker();
		var day = moment().format("YYYY-MM-DD");
		var startdate = day + " 00:00";
		var enddate = day + " 23:59";
		boss.data.startdate = startdate;
		boss.data.enddate = enddate;
		$("#CarNowDay").html(day);
		$("#car_date_hidden").val(day);
		boss.initCarStatistics(boss.data);
	},
	initUserLayout: function(){
		var boss = this;

		boss.data = {};
		var day = moment().format("YYYY-MM-DD");
		boss.data.startdate = day + " 00:00";
		boss.data.enddate = day + " 23:59";
		$("#UserNowDay").html(day);
		$("#user_date_hidden").val(day);
		boss.initUserStatistics(boss.data);
	},
	initCameraEvent: function(){
		var boss = this;
		
		$("#yearCameraBtn").bind("click", function(){
			boss.data = {};
			$("#beforeCaremaBtn").attr("no", 0);
			$("#nextCaremaBtn").attr("no", 0);
			var year = moment().format("YYYY");
			var day = moment().format("YYYY-MM-DD");
			$("#CameraNowDay").html(day);
			$("#camera_date_hidden").val(year);
			boss.data.startdate = year + "-01-01 00:00";
			boss.data.enddate = year + "-12-31 23:59";
			boss.initCameraStatistics(boss.data);
		});
		
		$("#monthCameraBtn").bind("click", function(){
			boss.data = {};
			$("#beforeCameraBtn").attr("no", 0);
			$("#nextCameraBtn").attr("no", 0);
			var month = moment().format("YYYY-MM");
			var days = moment().daysInMonth();
			var day = moment().format("YYYY-MM-DD");
			$("#CameraNowDay").html(day);
			$("#camera_date_hidden").val(month);
			boss.data.startdate = month + "-01 00:00";
			boss.data.enddate = month + "-" + days + " 23:59";
			boss.initCameraStatistics(boss.data);
		});
		
		$("#dayCameraBtn").bind("click", function(){
			boss.data = {};
			$("#beforeCameraBtn").attr("no", 0);
			$("#nextCameraBtn").attr("no", 0);
			var day = moment().format("YYYY-MM-DD");
			$("#CameraNowDay").html(day);
			$("#camera_date_hidden").val(day);
			boss.data.startdate = day + " 00:00";
			boss.data.enddate = day + " 23:59";
			boss.initCameraStatistics(boss.data);
		});
		
		$("#beforeCameraBtn").bind("click", function(){
			boss.data = {};
			var num1 = parseInt($(this).attr("no"));
			var num2 = parseInt($("#nextCameraBtn").attr("no"));
			var num = num1 + 1;
			$(this).attr("no", num);
			var day = moment().add("days", num2 - num).format("YYYY-MM-DD");
			boss.data.startdate = day + " 00:00";
			boss.data.enddate = day + " 23:59";
			$("#CameraNowDay").html(day);
			$("#camera_date_hidden").val(day);
			boss.initCameraStatistics(boss.data);
		});
		
		$("#nextCameraBtn").bind("click", function(){
			boss.data = {};
			var num1 = parseInt($("#beforeCameraBtn").attr("no"));
			var num2 = parseInt($(this).attr("no"));
			var num = num2 + 1;
			$(this).attr("no", num);
			var day = moment().add("days", num - num1).format("YYYY-MM-DD");
			boss.data.startdate = day + " 00:00";
			boss.data.enddate = day + " 23:59";
			$("#CameraNowDay").html(day);
			$("#camera_date_hidden").val(day);
			boss.initCameraStatistics(boss.data);
		});
		
		$("#returnCameraBtn").bind("click", function(){
			$("#camera_statistics_grid, #CameraStatistics").show();
			$("#camera_statistics_grid_low, #CameraStatistics_low").hide();
			$(this).hide();
		});
	},
	initCarEvent: function(){
		var boss = this;
		
		$("#yearCarBtn").bind("click", function(){
			boss.data = {};
			$("#beforeCarBtn").attr("no", 0);
			$("#nextCarBtn").attr("no", 0);
			var year = moment().format("YYYY");
			var day = moment().format("YYYY-MM-DD");
			$("#CarNowDay").html(day);
			$("#car_date_hidden").val(year);
			boss.data.startdate = year + "-01-01 00:00";
			boss.data.enddate = year + "-12-31 23:59";
			boss.initCarStatistics(boss.data);
		});
		
		$("#monthCarBtn").bind("click", function(){
			boss.data = {};
			$("#beforeCarBtn").attr("no", 0);
			$("#nextCarBtn").attr("no", 0);
			var month = moment().format("YYYY-MM");
			var day = moment().format("YYYY-MM-DD");
			$("#CarNowDay").html(day);
			$("#car_date_hidden").val(month);
			var today = moment().format("D");
			if(parseInt(today) >= 26){
				var nextMonth = moment().add(1,"month").format("YYYY-MM");
				boss.data.startdate = month + "-26 00:00";
				boss.data.enddate = nextMonth + "-26 23:59";
			}else{
				var beforeMonth = moment().add(-1,"month").format("YYYY-MM");
				boss.data.startdate = beforeMonth + "-26 00:00";
				boss.data.enddate = month + "-26 23:59";
			}
			boss.initCarStatistics(boss.data);
		});
		
		$("#dayCarBtn").bind("click", function(){
			boss.data = {};
			$("#beforeCarBtn").attr("no", 0);
			$("#nextCarBtn").attr("no", 0);
			var day = moment().format("YYYY-MM-DD");
			$("#CarNowDay").html(day);
			$("#car_date_hidden").val(day);
			boss.data.startdate = day + " 00:00";
			boss.data.enddate = day + " 23:59";
			boss.initCarStatistics(boss.data);
		});
		
		$("#beforeCarBtn").bind("click", function(){
			boss.data = {};
			var num1 = parseInt($(this).attr("no"));
			var num2 = parseInt($("#nextCarBtn").attr("no"));
			var num = num1 + 1;
			$(this).attr("no", num);
			var day = moment().add("days", num2 - num).format("YYYY-MM-DD");
			boss.data.startdate = day + " 00:00";
			boss.data.enddate = day + " 23:59";
			$("#CarNowDay").html(day);
			$("#car_date_hidden").val(day);
			boss.initCarStatistics(boss.data);
		});
		
		$("#nextCarBtn").bind("click", function(){
			boss.data = {};
			var num1 = parseInt($("#beforeCarBtn").attr("no"));
			var num2 = parseInt($(this).attr("no"));
			var num = num2 + 1;
			$(this).attr("no", num);
			var day = moment().add("days", num - num1).format("YYYY-MM-DD");
			boss.data.startdate = day + " 00:00";
			boss.data.enddate = day + " 23:59";
			$("#CarNowDay").html(day);
			$("#car_date_hidden").val(day);
			boss.initCarStatistics(boss.data);
		});
		
		$("#TextCarBtn").bind("click", function(){
			boss.data = sbl.getFormData("CarTimeTr", false);
			boss.initCarStatistics(boss.data);
		});
		
		$("#selectTimeBtn").bind("click",function(){
			$("#CarBtnTr").hide();
			$("#CarTimeTr").show();
		});
		
		$("#ButtonCarBtn").bind("click", function(){
			$("#CarTimeTr").hide();
			$("#CarBtnTr").show();
		});
		
		$("#returnCarBtn1, #returnCarBtn2").bind("click", function(){
			$("#car_statistics_grid, #CarStatistics").show();
			$("#car_statistics_grid_low, #CarStatistics_low").hide();
			$("#returnCarBtn1, #returnCarBtn2").hide();
		});
	},
	initUserEvent: function(){
		var boss = this;
		
		$("#yearUserBtn").bind("click", function(){
			boss.data = {};
			$("#beforeUserBtn").attr("no", 0);
			$("#nextUserBtn").attr("no", 0);
			var year = moment().format("YYYY");
			var day = moment().format("YYYY-MM-DD");
			$("#UserNowDay").html(day);
			$("#user_date_hidden").val(year);
			boss.data.startdate = year + "-01-01 00:00";
			boss.data.enddate = year + "-12-31 23:59";
			boss.initUserStatistics(boss.data);
		});
		
		$("#monthUserBtn").bind("click", function(){
			boss.data = {};
			$("#beforeUserBtn").attr("no", 0);
			$("#nextUserBtn").attr("no", 0);
			var month = moment().format("YYYY-MM");
			var days = moment().daysInMonth();
			var day = moment().format("YYYY-MM-DD");
			$("#UserNowDay").html(day);
			$("#user_date_hidden").val(month);
			boss.data.startdate = month + "-01 00:00";
			boss.data.enddate = month + "-" + days + " 23:59";
			boss.initUserStatistics(boss.data);
		});
		
		$("#dayUserBtn").bind("click", function(){
			boss.data = {};
			$("#beforeUserBtn").attr("no", 0);
			$("#nextUserBtn").attr("no", 0);
			var day = moment().format("YYYY-MM-DD");
			$("#UserNowDay").html(day);
			$("#user_date_hidden").val(day);
			boss.data.startdate = day + " 00:00";
			boss.data.enddate = day + " 23:59";
			boss.initUserStatistics(boss.data);
		});
		
		$("#beforeUserBtn").bind("click", function(){
			boss.data = {};
			var a = parseInt($(this).attr("no"));
			var b = parseInt($("#nextUserBtn").attr("no"));
			var num = a + 1;
			$(this).attr("no", num);
			var day = moment().add("days", (b - num)).format("YYYY-MM-DD");
			boss.data.startdate = day + " 00:00";
			boss.data.enddate = day + " 23:59";
			$("#UserNowDay").html(day);
			$("#user_date_hidden").val(day);
			boss.initUserStatistics(boss.data);
		});
		
		$("#nextUserBtn").bind("click", function(){
			boss.data = {};
			var a = parseInt($("#beforeUserBtn").attr("no"));
			var b = parseInt($(this).attr("no"));
			var num = b + 1;
			$(this).attr("no", num);
			var day = moment().add("days", (num - a)).format("YYYY-MM-DD");
			boss.data.startdate = day + " 00:00";
			boss.data.enddate = day + " 23:59";
			$("#UserNowDay").html(day);
			$("#user_date_hidden").val(day);
			boss.initUserStatistics(boss.data);
		});
	},
	initCameraStatistics:function(data){
		var boss = this;
		$("#camera_statistics_grid_low").hide();
		var cameraTotal = [];
		ManagerGrid.grid({
			url: burl + "/Statistics/StatisticsCameraAndHouse.do",
			Data: data,
			PageSize:300,
			Checkbox: true,
			columns: [{
				text: "序号", field: "ROWNUM"
			}, {
				text: "单位", field: "DEPTNAME"
			}, {
				text: "群防力量数", field: "USER_COUNT", total: true, defaultValue: 0
			}, {
				text: "当日采集数", field: "NOW_COUNT", total: true, defaultValue: 0
			}, {
				text: "未审核总数", field: "UNCHECK_COUNT", total: true, defaultValue: 0
			}, {
				text: "总采集总数", field: "ALL_COUNT", total: true, defaultValue: 0
			}],
			OnRender: function(d){
				$("#CameraStatistics, #CameraStatistics_low").hide();
				if(d._valueType = "total"){
					$("#CameraStatistics").html("当日采集数："+d.NOW_COUNT+"，未审核数总数："+d.UNCHECK_COUNT+"，总采集数："+d.ALL_COUNT).show();
				}
				if(d.DEPTNAME != null){
					d.DEPTNAME = "<a style='color: red;' tag='CameraJqStatisticsList' deptfullid='" + d.ID + "'>" + d.DEPTNAME + "</a>";
					if(d.NOW_COUNT != null){
						d.NOW_COUNT = "<a style='color: red;' tag='showPcsUserList' deptfullid='" + d.ID + "'>" + d.NOW_COUNT + "</a>";
					}else{
						d.NOW_COUNT = "<a style='color: red;' tag='showPcsUserList' deptfullid='" + d.ID + "'>0</a>";
					}
				}
				return d;
			},
			OnComplete: function(){
				$("a[tag='showPcsUserList'], a[tag='CameraJqStatisticsList']").bind("click",function(){
					data.id = $(this).attr("deptfullid");
					var tag = $(this).attr("tag");
					if(tag == "showPcsUserList"){
						boss.showCameraAndHouseUserList(data);
					}else if(tag == "CameraJqStatisticsList"){
						boss.showCameraStatisticsByDept(data);
					}
				});
			}
		}, "camera_statistics_grid");
		$("#camera_statistics_grid").show();
		$("#camera_statistics_grid").attr("loaded", "loaded");
	},
	showCameraAndHouseUserList: function(data){
		var boss = this;
		
		boss.dialog = sbl.dialog({
			width: 700,
			height:520,
			contentDivId:"PcsUserStatisticsList",
			OnComplete:function(){
				ManagerGrid.grid({
					url: burl + "/Statistics/getPcsCameraAndHouseUserList.do",
					Data: data,
					columns: [{
						text: "姓名", field: "SHOWNAME"
					},{
						text: "单位", field: "DEPTNAME"
					}, {
						text: "摄像头总数", field: "CAMERA_COUNT", defaultValue: 0
					}, {
						text: "合格数量", field: "CAMERA_PASSCOUNT", defaultValue: 0
					},{
						text: "监控室总数", field: "HOUSE_COUNT", defaultValue: 0
					}, {
						text: "合格数量", field: "HOUSE_PASSCOUNT", defaultValue: 0
					}],
					OnRender: function(d){
						if(d.CAMERA_COUNT != null){
							d.CAMERA_COUNT = "<span style='color: red;'>" + d.CAMERA_COUNT + "<span>";
						}
						if(d.HOUSE_COUNT != null){
							d.HOUSE_COUNT = "<span style='color: red;'>" + d.HOUSE_COUNT + "<span>";
						}
						return d;
					},
					OnComplete: function(){
					}
				}, "PcsUserStatisticsList");
			}
		});
	},
	showCameraStatisticsByDept: function(data){
		var boss = this;
		$("#camera_statistics_grid").hide();
		ManagerGrid.grid({
			url: burl + "/Statistics/StatisticsJQ.do",
			Data: data,
			PageSize: 300,
			columns: [{
				text: "上级单位", field: "PCS"
			}, {
				text: "单位", field: "DEPTNAME"
			}, {
				text: "摄像头总数", field: "CAMERA_COUNT",total:true,defaultValue:0
			}, {
				text: "审核数量", field: "CAMERA_CHECK_COUNT",total:true,defaultValue:0
			}, {
				text: "通过数量", field: "CAMERA_PASS_COUNT",total:true,defaultValue:0
			}, {
				text: "未通过数量", field: "CAMERA_UNPASS_COUNT",total:true,defaultValue:0
			}, {
				text: "|", field: "split"
			},{
				text: "监控室总数", field: "HOUSE_COUNT",total:true,defaultValue:0
			}, {
				text: "审核数量", field: "HOUSE_CHECK_COUNT",total:true,defaultValue:0
			}, {
				text: "通过数量", field: "HOUSE_PASS_COUNT",total:true,defaultValue:0
			}, {
				text: "未通过数量", field: "HOUSE_UNPASS_COUNT",total:true,defaultValue:0
			},{
				text: "操作", field: "todo"
			}],
			OnRender: function(d){
				$("#CameraStatistics, #CameraStatistics_low").hide();
				if(d._valueType = "total"){
					$("#CameraStatistics_low").html("当日采集数==>摄像头："+d.CAMERA_COUNT+"，监控室："+d.HOUSE_COUNT).show();
				}
				if(d.CAMERA_COUNT != null){
					d.CAMERA_COUNT = "<span style='color: red;'>" + d.CAMERA_COUNT + "</span>";
				}else{
					d.CAMERA_COUNT = "<span style='color: red;'>0</span>";
				}
				if(d.HOUSE_COUNT != null){
					d.HOUSE_COUNT = "<span style='color: red;'>" + d.HOUSE_COUNT + "</span>";
				}else{
					d.HOUSE_COUNT = "<span style='color: red;'>0</span>";
				}
				if(d.ID != null){
					d.todo = "<a tag='getCameraUserStatisticsList' deptfullid='" + d.ID + "'>详情</a>";
				}
				d.split = "|";
				return d;
			},
			OnComplete: function(){
				$("a[tag='getCameraUserStatisticsList']").bind("click",function(){
					data.low_id = $(this).attr("deptfullid");
					boss.showCameraUserStatisticsList(data);
				});
			}
		}, "camera_statistics_grid_low");
		$("#camera_statistics_grid_low").show();
		$("#returnCameraBtn").show();
	},
	showCameraUserStatisticsList:function(data){
		var boss = this;
		
		boss.dialog = sbl.dialog({
			height:450,
			contentDivId:"UserStatisticsList",
			OnComplete:function(){
				ManagerGrid.grid({
					url: burl + "/Statistics/getCameraUserStatisticsList.do",
					Data: data,
					columns: [{
						text: "姓名", field: "SHOWNAME"
					},{
						text: "单位", field: "DEPTNAME"
					}, {
						text: "摄像头总数", field: "CAMERA_COUNT", total: true, defaultValue: 0
					}, {
						text: "合格数量", field: "CAMERA_PASSCOUNT", total: true, defaultValue: 0
					},{
						text: "监控室总数", field: "HOUSE_COUNT", total: true, defaultValue: 0
					}, {
						text: "合格数量", field: "HOUSE_PASSCOUNT", total: true, defaultValue: 0
					}],
					OnRender: function(d){
						return d;
					},
					OnComplete: function(){
					}
				}, "UserStatisticsList");
			}
		});
	},
	initCarStatistics: function(data){
		var boss = this;
		$("#car_statistics_grid_low").hide();
		ManagerGrid.grid({
			url: burl + "/Statistics/StatisticsCar.do",
			Data: data,
			PageSize: 30,
			columns: [{
				text: "序号", field: "ROWNUM"
			}, {
				text: "单位", field: "DEPTNAME"
			}, {
				text: "车辆采集数", field: "CAR_NUM", total: true, defaultValue: 0
			}, {
				text: "扣除数", field: "CAR_ABNORMAL_NUM", total: true, defaultValue: 0
			}, {
				text: "有效采集数", field:"CAR_NORMAL_NUM", total: true, defaultValue: 0
			}],
			OnRender: function(d){
				$("#CarStatistics, #CarStatistics_low").hide();
				if(d._valueType = "total"){
					$("#CarStatistics").html("当日采集数：" + d.CAR_NUM).show();
				}
				if(d.DEPTNAME != null){
					if(d.CAR_NORMAL_NUM != null){
						d.CAR_NORMAL_NUM = "<a style='color: blue;' tag='getPcsCarUserList' deptfullid='" + d.ID + "'>"+d.CAR_NORMAL_NUM+"</a>";
					}else{
						d.CAR_NORMAL_NUM = "<a style='color: blue;' tag='getPcsCarUserList' deptfullid='" + d.ID + "'>0</a>";
					}
					d.DEPTNAME = "<a style='color: red;' tag='CarJqStatisticsList' deptfullid='" + d.ID + "'>" + d.DEPTNAME + "</a>";
					if(d.CAR_NUM != null){
						d.CAR_NUM = "<a style='color: bule;' tag='getPcsCarUserList' deptfullid='" + d.ID + "'>" + d.CAR_NUM + "</a>";
					}else{
						d.CAR_NUM = "<a style='color: bule;' tag='getPcsCarUserList' deptfullid='" + d.ID + "'>0</a>";
					}
					if(d.CAR_ABNORMAL_NUM != null){
						d.CAR_ABNORMAL_NUM = "<a style='color: red;' tag='getPcsCarUserList' deptfullid='" + d.ID + "'>" + "-"+d.CAR_ABNORMAL_NUM/30+"*30"+ "</a>";
					}else{
						d.CAR_ABNORMAL_NUM = "<a style='color: red;' tag='getPcsCarUserList' deptfullid='" + d.ID + "'>0</a>";
					}
				
				}
				return d;
			},
			OnComplete: function(){
				$("a[tag='getPcsCarUserList'], a[tag='CarJqStatisticsList']").bind("click", function(){
					data.id = $(this).attr("deptfullid");
					var tag = $(this).attr("tag");
					if(tag == "getPcsCarUserList"){
						boss.showPcsUserList(data);
					}else if(tag == "CarJqStatisticsList"){
						boss.CarJqStatitics(data);
					}
				});
			}
		}, "car_statistics_grid");
		$("#car_statistics_grid").show();
		$("#car_statistics_grid").attr("loaded", "loaded");
	},
	showPcsUserList: function(data){
		var boss = this;
		
		boss.dialog = sbl.dialog({
			width: 800,
			height: 1000,
			contentDivId: "PcsUserStatisticsList",
			OnComplete:function(){
				ManagerGrid.grid({
					url: burl + "/Statistics/getPcsCarUserStatisticsList.do",
					Data: data,
					PageSize: 30,
					columns: [{
						text: "姓名", field: "SHOWNAME"
					},{
						text: "单位", field: "PCSNAME"
					}, {
						text: "车辆采集数", field: "CAR_NUM", defaultValue: 0
					}, {
						text: "扣除数", field: "CAR_ABNORMAL_NUM", defaultValue: 0
					}, {
						text: "有效采集数", field: "CAR_NORMAL_NUM", defaultValue: 0
					}],
					OnRender: function(d){
						var NORMAL_NUM=0;
						if(d.CAR_NUM != null){
							d.CAR_NUM = "<span style='color: bule;'>" + d.CAR_NUM + "</span>";
						}
						if(d.CAR_ABNORMAL_NUM != null){
							d.CAR_ABNORMAL_NUM = "<span style='color: red;'>" + "-"+d.CAR_ABNORMAL_NUM/30+"*30"+ "</span>";
						}
						if(d.CAR_NORMAL_NUM != null){
								d.CAR_NORMAL_NUM = "<a style='color: blue;' tag='getPcsCarUserList' deptfullid='" + d.ID + "'>"+d.CAR_NORMAL_NUM+"</a>";
						}else{
								d.CAR_NORMAL_NUM = "<a style='color: blue;' tag='getPcsCarUserList' deptfullid='" + d.ID + "'>0</a>";
							}	
						if(d.JQNAME != null){
							if(d.ZRQNAME != null){
								d.PCSNAME = d.PCSNAME + "-" + d.JQNAME + "-" + d.ZRQNAME;
							}else{
								d.PCSNAME = d.PCSNAME + "-" + d.JQNAME;
							}
						}else{
							d.PCSNAME = d.PCSNAME;
						}
						return d;
					},
					OnComplete: function(){
					}
				}, "PcsUserStatisticsList");
			}
		});
	},
	CarJqStatitics: function(data){
		var boss = this;

		$("#car_statistics_grid").hide();
		ManagerGrid.grid({
			url: burl + "/Statistics/StatisticsCarJq.do",
			Data: data,
			PageSize: 30,
			columns: [{
				text: "序号", field: "ROWNUM"
			}, {
				text: "上级单位", field: "PCS"
			}, {
				text: "单位", field: "DEPTNAME"
			}, {
				text: "群防力量数", field: "USER_COUNT", total: true, defaultValue: 0
			}, {
				text: "当日采集数", field: "CAR_NUM", total: true, defaultValue: 0
			}],
			OnRender: function(d){
				$("#CarStatistics, #CarStatistics_low").hide();
				if(d._valueType = "total"){
					$("#CarStatistics_low").html("当日采集数：" + d.CAR_NUM).show();
				}
				if(d.DEPTNAME != null){
					d.DEPTNAME = "<span style='color: red;'>" + d.DEPTNAME + "</span>";
					if(d.CAR_NUM != null){
						d.CAR_NUM = "<a style='color: red;' tag='getJqCarUserList' deptfullid='" + d.ID + "'>" + d.CAR_NUM + "</a>";
					}else{
						d.CAR_NUM = "<a style='color: red;' tag='getJqCarUserList' deptfullid='" + d.ID + "'>0</a>";
					}
				}
				return d;
			},
			OnComplete: function(){
				$("a[tag='getJqCarUserList']").bind("click", function(){
					data.low_id = $(this).attr("deptfullid");
					boss.carUserStatisticsList(data);
				});
			}
		}, "car_statistics_grid_low");
		$("#car_statistics_grid_low, #returnCarBtn1, #returnCarBtn2").show();
	},
	carUserStatisticsList: function(data){
		var boss = this;
		sbl.dialog({
			width: 600,
			height: 1000,
			contentDivId:"UserStatisticsList",
			OnComplete:function(){
				ManagerGrid.grid({
					url: burl + "/Statistics/getJqCarUserStatisticsList.do",
					Data: data,
					PageSize: 30,
					columns: [{
						text: "姓名", field: "SHOWNAME"
					},{
						text: "单位", field: "JQNAME"
					}, {
						text: "当日车辆采集总数", field: "CAR_NUM", defaultValue: 0
					}],
					OnRender: function(d){
						if(d.ZRQNAME != null){
							d.JQNAME = d.PCSNAME + "-" + d.JQNAME + "-" + d.ZRQNAME;
						}else{
							d.JQNAME = d.PCSNAME + "-" + d.JQNAME;
						}
						return d;
					},
					OnComplete: function(){
					}
				}, "UserStatisticsList");
			}
		});
	},
	initUserStatistics: function(data){
		var boss = this;
		ManagerGrid.grid({
			url: burl + "/Statistics/StatisticsUser.do",
			Data: data,
			PageSize: 30,
			columns: [{
				text: "序号", field: "ROWNUM"
			}, {
				text: "单位", field: "DEPTNAME"
			}, {
				text: "当日新增数", field: "NOW_NUM", total: true, defaultValue: 0
			}, {
				text: "总群防力量数", field: "ALL_NUM", total: true, defaultValue: 0
			}],
			OnRender: function(d){
				return d;
			},
			OnComplete: function(){
				
			}
		}, "user_statistics_grid");
		$("#user_statistics_grid").attr("loaded", "loaded");
	}
};
$(function(){
	StatisticsM.init();
});